package com.gxljc.bear.crawler.util;

/**
 * Triple
 *
 * @author tanghaitao
 * @date 15-10-15
 */
public class Triple<T1, T2, T3> {
	public T1 first = null;
	public T2 second = null;
	public T3 third = null;

	public Triple(T1 t1, T2 t2, T3 t3) {
		first = t1;
		second = t2;
		third = t3;
	}

	public T1 getFirst() {
		return first;
	}

	public T2 getSecond() {
		return second;
	}

	public T3 getThird() {
		return third;
	}

	private static boolean equals(Object x, Object y) {
		return (x == null && y == null) || (x != null && x.equals(y));
	}

	@Override
	@SuppressWarnings("unchecked")
	public boolean equals(Object other) {
		return other instanceof Triple
				&& equals(first, ((Triple<T1, T2, T3>) other).first)
				&& equals(second, ((Triple<T1, T2, T3>) other).second)
				&& equals(third, ((Triple<T1, T2, T3>) other).third);
	}


	@Override
	public String toString() {
		return "{" + getFirst() + "," + getSecond() + "," + getThird() + "}";
	}
}